import QtQuick 1.0

Rectangle {
    id: button
    state: "normal"

    property color buttonColor: "orange"
    property alias buttonText: text.text

    signal clicked();

    Text {
        id: text
        text: buttonText
        anchors.centerIn: parent
    }

    MouseArea {
        id: buttonMouseArea
        anchors.fill: parent

        hoverEnabled: true

        onEntered: button.state = "hovered"
        onExited: button.state = "normal"

        onClicked: button.clicked();
    }

    states: [
        State {
            name: "hovered"
            PropertyChanges { target: button; opacity: 1 }
        },
        State {
            name: "normal"
            PropertyChanges { target: button; opacity: 0.7 }
        }
    ]

    Behavior on opacity { NumberAnimation { duration: 100 } }

    color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
}
